<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Character classes</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="parle.regex.chars.html">« Character representations</a></li>
      <li style="float: right;"><a href="parle.regex.unicodecharclass.html">Unicode character classes »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="parle.pattern.matching.html">Pattern matching</a></li>
    <li>Character classes</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="parle.regex.charclass" class="section">
  <h2 class="title">Character classes</h2>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Character classes</strong></caption>
    
     <thead>
      <tr>
       <th>Sequence</th><th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>[...]</td><td>A single character listed or contained within a listed range. Ranges can be combined with the <code class="literal">{+}</code> and <code class="literal">{-}</code> operators. For example <code class="literal">[a-z]{+}[0-9]</code> is the same as <code class="literal">[0-9a-z]</code> and <code class="literal">[a-z]{-}[aeiou]</code> is the same as <code class="literal">[b-df-hj-np-tv-z]</code>.</td>
      </tr>

      <tr>
       <td>[^...]</td><td>A single character not listed and not contained within a listed range.</td>
      </tr>

      <tr>
       <td>.</td><td>Any character, default <code class="literal">[^\n].</code></td>
      </tr>

      <tr>
       <td>\d</td><td>Digit character, <code class="literal">[0-9]</code>.</td>
      </tr>

      <tr>
       <td>\D</td><td>Non-digit character, <code class="literal">[^0-9]</code>.</td>
      </tr>

      <tr>
       <td>\s</td><td>White space character, <code class="literal">[ \t\n\r\f\v]</code>.</td>
      </tr>

      <tr>
       <td>\S</td><td>Non-white space character, <code class="literal">[^ \t\n\r\f\v]</code>.</td>
      </tr>

      <tr>
       <td>\w</td><td>Word character, <code class="literal">[a-zA-Z0-9_]</code>.</td>
      </tr>

      <tr>
       <td>\W</td><td>Non-word character, <code class="literal">[^a-zA-Z0-9_]</code>.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div></div></div></body></html>